package com.example.yskjproject.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.recyclerview.widget.RecyclerView;

import com.example.yskjproject.R;
import com.example.yskjproject.model.OrderListModel;

import java.util.ArrayList;
import java.util.List;

public class RechargeRecordAdapter extends RecyclerView.Adapter<RechargeRecordAdapter.ViewHolder> {
    private List<OrderListModel.OrderListBean> mOrderListMode = new ArrayList<>();
    public void addData(OrderListModel rechargeRecordListModel) {
        mOrderListMode = rechargeRecordListModel.getOrder_list();
        notifyDataSetChanged();
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_recharge_record, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        OrderListModel.OrderListBean rechargeRecordModel = mOrderListMode.get(position);
//        holder.tvOrderNumber.setText(rechargeRecordModel.);
        holder.tvRechargeAmount.setText(rechargeRecordModel.getOriginal_price() + "");
        holder.tvRechargeDate.setText(rechargeRecordModel.getCreated_at() + "");
        holder.tvOrderNumber.setText(rechargeRecordModel.getOrder_sn() + "");

    }

    @Override
    public int getItemCount() {
        return mOrderListMode.size();
    }

    public static class ViewHolder extends RecyclerView.ViewHolder {
        AppCompatTextView tvOrderNumber;
        AppCompatTextView tvRechargeAmount;
        AppCompatTextView tvRechargeDate;
        AppCompatTextView tvOrderStatus;

        public ViewHolder(View itemView) {
            super(itemView);
            tvOrderNumber = itemView.findViewById(R.id.tv_order_number);
            tvRechargeAmount = itemView.findViewById(R.id.tv_recharge_amount);
            tvRechargeDate = itemView.findViewById(R.id.tv_recharge_date);
            tvOrderStatus = itemView.findViewById(R.id.tv_order_status);
        }
    }
}

